#! /usr/bin/env python
# -*- coding: utf-8 -*-

# @author: xmj
# @date: 2023/5/2

import os
import yaml
import logging


class ParseConfig:
    """
    解析配置文件
    """

    def __init__(self, config_dir):
        """
        :param config_dir: 配置文件相对路径
        """
        self.config_dir = config_dir

    def parse_conf(self):
        """
        解析配置文件
        :return:
        """
        with open(self.config_dir + '\\config.yml', 'r', encoding='utf-8') as f:
            data = yaml.load(f, Loader=yaml.FullLoader)
        return data

    def parse_url(self):
        """
        解析URL
        :return:
        """
        with open(self.config_dir + '\\urls.yml', 'r', encoding='utf-8') as f:
            urls = yaml.load(f, Loader=yaml.FullLoader)['urls']
        return urls

    def parse_endpoint(self):
        """
        解析endpoint
        :return:
        """
        with open(self.config_dir + '\\endpoints.yml', 'r', encoding='utf-8') as f:
            endpoints = yaml.load(f, Loader=yaml.FullLoader)['endpoints']
        return endpoints

